package student.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.util.MyLog;

import edu.student.models.User;

public class Logout extends ActionSupport {

private static final long serialVersionUID = 1L;
private String submit;
private String role="";
private String username="";
private String user_id="";
private String email_id="";


public String getUsername() {
	return username;
}
public void setUsername(String username) {
	this.username = username;
}
public String getUser_id() {
	return user_id;
}
public void setUser_id(String user_id) {
	this.user_id = user_id;
}
public String getEmail_id() {
	return email_id;
}
public void setEmail_id(String email_id) {
	this.email_id = email_id;
}
public String getRole() {
	return role;
}
public void setRole(String role) {
	this.role = role;
}
public String getSubmit() {
	return submit;
}
public void setSubmit(String submit) {
	this.submit = submit;
}

	public String execute() throws Exception {
		
			MyLog.log("In logout");
			Map<String, Object> session = ActionContext.getContext().getSession();
			if(session.get("user") != null && session.get("user") != ""){
				User user = (User) session.get("user");
				System.out.println("*********"+user.getRollNor());
			User.updateLastLogin(user.getRollNor());	
			session.remove("user");
			}
			
		
		return "exit";
	}

}
